'use strict';

module.exports = app => {
  const { INTEGER, STRING, DATE, TEXT, NOW } = app.Sequelize;

  const Article = app.model.define('article', {
    article_id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    article_title: {
      type: STRING,
      defaultValue: '',
      allowNull: false,
    },
    short_title: {
      type: STRING,
      defaultValue: '',
    },
    article_cover: {
      type: STRING,
      defaultValue: '',
    },
    description: {
      type: STRING,
      defaultValue: '',
    },
    keyword: {
      type: STRING,
      defaultValue: '',
    },
    created_at: {
      type: DATE,
      defaultValue: NOW,
    },
    update_at: {
      type: DATE,
      defaultValue: NOW,
    },
    owner: {
      type: STRING,
      defaultValue: '',
    },
    visited: {
      type: INTEGER,
      defaultValue: 0,
    },
    star: {
      type: INTEGER,
      defaultValue: 0,
    },
    content: {
      type: TEXT,
      defaultValue: '',
    },
    cat_id: {
      type: INTEGER,
      defaultValue: 0,
      allowNull: false,
    },
    is_recomm: {
      type: INTEGER,
      defaultValue: 0,
    },
    is_hot: {
      type: INTEGER,
      defaultValue: 0,
    },
    is_tou: {
      type: INTEGER,
      defaultValue: 0,
    },
  }, {
    timestamps: false,
    tableName: 'l_article',
  })

  return Article;
}
